/************************************************************************
* Programmer:  Philippe Gambling
*
* Course:  CSCI 4534
*
* Date:  February 19, 2009
*
* Environment:  GCC 3.2.2 running on diamond.rocks.uhcl.edu
*
* Files Included: queue.h, queue.c
*
* Purpose:  Defines a simple generic queue structure using a linked list.
*
***********************************************************************/ 

#ifndef _QUEUE_H
#define _QUEUE_H

#include "node.h"


/*
  Queue data attributes
  
  **** Naming conventions ****
  * _ = "private" variables
  * p = pointer
  * i = integer
  ****************************
  _phead - Pointer to front of queue.
  _ptail - Pointer to back of queue.
  _piterator - Pointer used to iterate through queue.
  _idatasize - Byte size of each node's data.
  _icount - Number of nodes in the queue.

*/  
typedef struct queue
{
  Node _phead;
  Node _ptail;
  Node _piterator;
  size_t _idatasize;
  unsigned short _icount;
} * Queue;


/* Public Interfaces for Queue */
Queue new_Queue(size_t);
int Queue_AddBack(const Queue, const void *);
int Queue_RemoveFront(const Queue, void *);
int Queue_Empty(const Queue);
int Queue_Size(const Queue);
int Queue_Clear(const Queue);
int Queue_NextNode(const Queue, void *);
int Queue_GetFront(const Queue, void *);
void Queue_StartIterator(const Queue);
void free_Queue(Queue);

/* Helper Functions */
#define QUEUE_PRINT_PROTO(type) void Queue_##type##Print(const Queue)
QUEUE_PRINT_PROTO(int);
QUEUE_PRINT_PROTO(char);
QUEUE_PRINT_PROTO(float);
#undef QUEUE_PRINT_PROTO

/* Error Codes */
#define EEND 0 /* END OF QUEUE */
#define SUCCESS 1
#define EMEMFAIL 2 
#define EEMPTY 3 


#endif
